<?php

// mbilling/BillingBundle/Entity/orders.php
namespace mbilling\BillingBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/*
 * типы заказов:
 * 1)виртуальный хостинг
 * 2)VPS
 * 3)FTP
 */

/**
 * @ORM\Entity
 */
class orders
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="datetime")
     */
    protected $created_at;
    
    /**
     * @ORM\Column(type="boolean")
     */
    protected $is_active;
    
    /**
     * @ORM\Column(type="integer")
     * @assert\NotBlank
     * @assert\Type("numeric")
     */
    protected $type;
    
    /**
     * @ORM\Column(type="integer")
     * @assert\NotBlank
     * @assert\Type("numeric")
     */
    protected $user_id;

    public function __construct()
    {
        $this->setCreatedAt(new \DateTime());
    }

    public function setId($id)
    {
        $this->id = $id;
    }
    public function getId()
    {
        return $this->id;
    }

    public function setCreatedAt($created_at)
    {
        $this->created_at = $created_at;
    }
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    public function setIsActive($is_active)
    {
        $this->is_active = $is_active;
    }
    public function getIsActive()
    {
        return $this->is_active;
    }
    
    public function setType($type)
    {
        $this->type = $type;
    }
    public function getType()
    {
        return $this->type;
    }

    public function setUserId($user_id)
    {
        $this->user_id = $user_id;
    }
    public function getUserId()
    {
        return $this->user_id;
    }
    
    public function isShared()
    {
        if ($this->type == '1')
            return true;
        else
            return false;
    }

    public function isVps()
    {
        if ($this->type == '2')
            return true;
        else
            return false;
    }
    
    public function initDefaultEntity()
    {
        $this->setIsActive('1');
        $this->setType('3');
        $this->setUserId('1');
        return $this;
    }  
}
?>
